import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/HelloFromVux'
import MoreInfo from '@/components/MoreInfo'

Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: [{
      path: '/share',
      name: 'Home',
      meta: {
        title: "抢车宝-分享"
      },
      component: Home
    },
    {
      path: '/moreinfo/:car_id',
      name: 'moreinfo',
      meta: {
        title: "更多信息"
      },
      component: MoreInfo
    }
  ]
})
router.beforeEach((to, from, next) => {
  if (to.meta.title) { //如果设置标题，拦截后设置标题
    document.title = to.meta.title
  }
  next()
})

export default router
